<!--
 * @Author: your name
 * @Date: 2021-08-03 13:36:05
 * @LastEditTime: 2021-08-12 13:26:42
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \getHome (2)\src\components\discounts\amend.vue
-->
<!--通知管理-->
<template>
  <div>
    <div class="herdertop">
      <img src="../../assets/top.png" alt="" class="topImg" />
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>通知管理</el-breadcrumb-item>
        <el-breadcrumb-item>通知管理</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="center" style="padding-top: 0px;">
      <div class="hander">通知管理</div>

      <!--  员工列表栏位-->

      <div class="entirety">
        <el-table :data="tableData" style="width: 100%">
          <el-table-column prop="msgType" label="通知类型" width="120">
            <template slot-scope="scope">
              <div>
                {{ scope.row.msgType }}
              </div>
            </template>
          </el-table-column>

          <el-table-column prop="tempSwitch" label="类型状态" width="500">
            <template slot-scope="scope">
              <el-switch
                v-model="scope.row.tempSwitch"
                :active-value="1"
                :inactive-value="0"
                active-text="开启"
                inactive-text="关闭"
                active-color="#fb8053"
                inactive-color="#dcdfe6"
                @change="switchChange($event, scope.row)"
              >
              </el-switch>
            </template>
          </el-table-column>
          <el-table-column fixed="right" label="操作">
            <template slot-scope="scope">
              <el-button
                @click="isJumpUrlSmsNOtice(scope.row.msgType)"
                style="color: #fc9e76;"
                type="text"
                size="small"
                v-if="scope.row.msgType == '短信通知'"
              >
                查看通知记录
              </el-button>
              <el-button
                @click="isJumpUrlSmsSend(scope.row.msgType)"
                style="color: #fc9e76;"
                type="text"
                size="small"
              >
                查看通知模板
              </el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      json_fields: {
        //导出Excel表格的表头设置
        员工姓名: "nickname",
        登录账号: "userName",
        员工状态: "staffStatus"
      },
      iSON: true,
      pageIndex: 1,
      pageSize: 20,
      total: 0,
      dialogTableVisible: false,
      dialogFormVisible: false,
      tableData: [],
      form: {
        name: "",
        region: "",
        date1: "",
        date2: "",
        delivery: false,
        type: [],
        resource: "",
        desc: ""
      },
      staffName: "",
      staffPhone: "",
      searchValue: "",
      userSearch: 0,

      formLabelWidth: "120px",
      staffSearch: [
        { value: 0, label: "员工姓名" },
        { value: 1, label: "登录账号" }
      ],
      StateData: "",
      business: [
        {
          statusCode: "1",
          statusName: "正常"
        },
        {
          statusCode: "2",
          statusName: "冻结"
        }
      ],
      multipleSelection: []
    };
  },
  activated() {
    this.DetailByPage();
  },

  methods: {
    // 跳转页面1
    isJumpUrlSmsSend(msgType) {
      //console.log("msgType,,,,,,", msgType);
      if (msgType == "服务消息") {
        this.$router.push({
          path: "/serviceNotice"
        });
      } else if (msgType == "系统通知") {
        this.$router.push({
          path: "/system"
        });
      } else {
        this.$router.push({
          path: "/smsNOtice"
        });
      }
    },
    //跳转页面2
    isJumpUrlSmsNOtice(staffCode) {
      this.$router.push({
        path: "/smsSend"
      });
    },

    //消息通知列表
    DetailByPage() {
      this.$http({
        url: `/messageadmin/message/MessageInform/findMessageInformList`,
        method: "GET"
      }).then(res => {
        this.tableData = res.data;
      });
    },

    switchChange(e, data) {
      //console.log(e, "aing");
      //console.log(data, "data");

      let message = "";
      if (e == 1) {
        message = "启用成功 !";
        this.$http({
          url: `/messageadmin/message/MessageInform/updateSwitchState`,
          method: "POST",
          data: {
            msgCode: data.msgCode,
            tempSwitch: 1
          }
        }).then(res => {
          if (res) return this.$message({ type: "success", message });
        });
      } else if (e == 0) {
        message = "停用成功 !";
        this.$http({
          url: `/messageadmin/message/MessageInform/updateSwitchState`,
          method: "POST",
          data: {
            msgCode: data.msgCode,
            tempSwitch: 0
          }
        }).then(res => {
          if (res) return this.$message({ type: "success", message });
        });
      }
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val;
      this.pageIndex = 1;
      this.DetailByPage();
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val;
      this.DetailByPage();
    }
  }
};
</script>
<style scoped lang="scss">
.herdertop {
  height: 8vh;
  display: flex;
  align-items: center;
  padding: 0 20px;
  box-sizing: border-box;
}
.topImg {
  margin-right: 20px;
}
.hander {
  width: 100%;
  height: 50px;
  line-height: 50px;
  font-size: 20px;
  font-weight: 900;
}
.news {
  margin-left: 16%;
}
.entirety {
  width: 95%;
  margin: 10px;
  border: 7px solid #fafafa;
  border-radius: 10px;
  .basic {
    font-size: 18px;
    font-weight: 900;
    margin-top: 2%;
    margin-bottom: 1%;

    margin-left: 1%;
  }
}

.overall {
  width: 100%;
  height: auto;
  display: flex;

  justify-content: space-between;
  margin-top: 3%;
  .left {
    width: 20%;
    height: auto;
  }
  .right {
    width: 80%;
    height: auto;
  }
}
.demo-input-suffix {
  margin-left: 2%;
}
.select {
  width: 65%;
  height: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .dialog-footer,
  .choice {
    margin-left: 2%;
  }
}
.userSearch {
  display: flex;
  /deep/ .el-input__inner {
    box-sizing: border-box;
    height: 40px;
    border-radius: 0;
    width: 132px;
    border: 1px solid #dcdfe6;
  }
  /deep/ .el-icon-arrow-up:before {
    position: relative;
    top: -4px;
  }
  /deep/ .el-button {
    height: 40px;
    border-radius: 0;
    background-color: #fff;
    border: 1px solid #dcdfe6;
    border-left: none;
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
    position: relative;
    .el-icon-search {
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
    }
  }
  /deep/ .el-input--suffix .el-input__inner {
    border-right: none;
  }
  /deep/ .el-input--suffix .el-input__inner {
    border-top-left-radius: 4px;
    border-bottom-left-radius: 4px;
  }
}
.selects {
  width: 55%;
  height: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .dialog-footer,
  .choice {
    margin-left: 2%;
  }
}

/deep/ .but {
  background: #fd7097;
  color: #fff;
  margin-bottom: 1%;
}
</style>
